package com.bracketbird.client.gui.club.tournament;


import com.google.gwt.event.dom.client.*;
import com.bracketbird.clientcore.appcontrol.*;
import com.bracketbird.clientcore.gui.*;
import com.bracketbird.clientcore.style.*;

/**
 *
 */
public class CreateTemplatePage extends SubPage<CreateTemplatePageController> {
    private TournamentSettingsPanel tournamentSettingsPanel;
    private ButtonPanel buttonPanel;

    public CreateTemplatePage() {
        super();
    }


    public void doInit() {

    
        getContent().add(new LabelComponent("A tournament is made of one or more stages. Add stages and specify their settings to create your template."), new TextLayout().padding(10, 0, 0, 0).sizeSmall().colorBaseDark());
        getContent().add(getTournamentSettingsPanel(), new TextLayout(null, "100%"));
        getContent().add(getButtonPanel());
    }

    public String getHeader() {
        return "Create a Template";
    }



    public TournamentSettingsPanel getTournamentSettingsPanel() {
        if (tournamentSettingsPanel == null) {
            tournamentSettingsPanel = new TournamentSettingsPanel(true);
        }
        return tournamentSettingsPanel;
    }

    public ButtonPanel getButtonPanel() {
        if (buttonPanel == null) {


            ButtonComponent createTemplate = new ButtonComponent("Create template");
            createTemplate.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    //TODO validate
                    CreateTemplatePageController.getInstance().saveTemplate();
                }
            });
            buttonPanel = new ButtonPanel(createTemplate);
        }
        return buttonPanel;
    }

    @Override
    protected void setSubPageHolder(Page subPage) {

    }

    public void clear() {
        //TODO;
    }

}